<?php include "verifica.php"; ?>
<html>
<head>
	<title>ABR</title>
</head>
<body>
	<div class="box">

		<?php
			include "topo.php";
			include "menu.php";
		?>		

			<div class="formulario">
            <?php 	
					include "conexao.php";

					$id = $_GET['id'];
					$sql_select = mysql_query("SELECT * FROM tb_item WHERE id = '$id' ");
					while($linha = mysql_fetch_array($sql_select)){
						$nome = $linha['nome'];
					}
				?>
				<fieldset>
					<legend>Cadastro de Item</legend>
						<form name="form1" action="crud_item.php?funcao=update&id=<?php echo $id ?>" method="POST">
							<h4>* Primeiro escolha clicando no editar do Item e depois edite os dados.</h4>
							<table>
								<tr>
									<td>Nome:</td>
									<td><input type="text" name="nome" id="nome" value="<?php echo $nome ?>"></td>
								</tr>
								<tr>
									<td></td>
									<td>
                                    	<input type="submit" value="Alterar" onClick="return validarItem()" />
                                    </td>
							</tr>
							</table>
						</form>
					<fieldset>
					<legend>Edição de Itens</legend>
						<table>
							<tr>
								<th>Nome</th>
								<th>Código</th>
								<th>Editar</th>
							</tr>
							<?php 
								include "conexao.php";
								$sql_select = mysql_query("SELECT * FROM tb_item ORDER BY nome");
								while($linha = mysql_fetch_array($sql_select)){ 
								$pega_id = $linha['id'];
								$pega_nome = $linha['nome'];

							?>
							<tr>
								<td><?php echo $pega_nome ?></td>
								<td align="center"><?php echo $pega_id ?></td>
								<td align="center"><a href="formulario_editar_item.php?funcao=edit&id=<?php echo $pega_id ?>"><img src="images/edit.png"></a></td>
							</tr>

							<?php } ?>

						</table>	
				</fieldset>
                </fieldset>
			</div><!--formulario-->

		<?php	
			include "rodape.php";
		?>

	</div><!--box-->
</body>
</html>